Called when toolbar item is clicked.

<div class="definition">
    onClick = function(event)
</div>

You can add event listener during the object creation:

<textarea class="javascript">
let toolbar = new w2toolbar({
    name  : 'toolbar',
    items : [
        { type: 'check',  id: 'item1', text: 'Check', icon: 'icon-page', checked: true },
        { type: 'radio',  id: 'item3',  group: '1', text: 'Radio 1', icon: 'icon-add' },
        { type: 'radio',  id: 'item4',  group: '1', text: 'Radio 2', icon: 'icon-add' }
    ],
    onClick(event) {
        console.log('item '+ event.target + ' is clicked.');
    }
});
</textarea>

or after the object has been created:

<textarea class="javascript">
w2ui.toolbar.on('click', function(event) {
    console.log('item '+ event.target + ' is clicked.');
});
</textarea>

You can add a listener to a toolbar item, see <a href="w2toolbar.items" class="property">.items</a> property. If toolbar
item is a menu, then the <span class="argument">event</span> will have a reference to a menu item user clicked (if any).
<div style="height: 10px"></div>

The event handler is called before the default action of the event is triggered. You can cancel the default action by calling
<span class="method">event.preventDefault()</span>. To perform an action
after the event is fully processed, define <span class="method">event.onComplete</span> function.
<div style="height: 10px;"></div>
See <a href="utils/events">events</a> page in utilities for more details.